package com.sgb.knowledgeshare.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.knowledgeshare.ShareConfig;
import com.sgb.knowledgeshare.view.fragment.ShareUserListFragment;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.util.MToast;
import com.swgk.core.view.entity.VideoListEntity;

import java.util.HashMap;
import java.util.Map;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class ShareUserListModel extends ViewModel {
    ShareUserListFragment shareuserlistfragment;
    public void setActivity(ShareUserListFragment shareUserListFragment) {
        shareuserlistfragment = shareUserListFragment;
    }

    //获取用户视频列表信息
    public void getVideoListData(int page,String userno, String userShareType) {
        Map map = new HashMap();
        map.put("pageNum", page);
        map.put("pageSize", "10");
        map.put("userNo", userno);
        map.put("type", userShareType);
        map.put("videoId", "");
      /*  if (shareuserlistfragment.isVisible()) {
            DialogHelper.showProgressDialog(shareuserlistfragment.getActivity(), null, "加载中...", 0, false, null).setCanceledOnTouchOutside(false);
        }*/
       ShareConfig.getInstance().getApi().getmyVodList(map).enqueue(new ICallBack<BaseEntity<VideoListEntity>>() {
           @Override
           public void onSuccess(BaseEntity<VideoListEntity> data) {
               if (data.getData() == null) {
                   return;
               }
               if (data.getState().equals(ShareConfig.RESPONSE_OK)) {
                   shareuserlistfragment.setVideoListData(data.getData());
               } else {
                   MToast.showToast(shareuserlistfragment.getActivity(), data.getMsg());
               }
           }
       });
    }


}
